<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Netbeans Example</title>
</head>
<body>

<h2>
JCalendarButton - Netbeans Component Example
</h2>

<p>
The JCalendarButton components are standard java beans, so they can be used in visual screen builders.
</p>

<p>
Here is an Example using the JCalendar components in netbeans.
</p>

<p>
First lets start with a Sample application that takes a date input:<br></br>
1. Create a new project with netbeans.<br></br>
2. Create a new visual screen (File -> New File -> Swing GUI Forms -> JFrameForum)<br></br>
3. Add my screen components and get a screen that looks something like this:<br></br>
<img src="images/netbeansvisualbuilder1.jpg"></img><br></br>
4. Now I write my text input date validation code. (if you want to see the source code at this point, <a href="code1/NewJFrame.java">here it is.</a>)<br></br>
<b>Now you're ready to add the JCalendar buttons. Remember when the user selects a date on the
JCalendar popup, a property change event is generated with the java <i>Date</i> as the new property value.</b><br></br>
5. If you haven't already added the JCalendar buttons to your palette, just right click the swing palette,
select Palette manager -> Add From Jar and select jcalendarbutton.jar from the lib folder. Click next,
then select JCalendarButton and JTimeButton from the screen. Add them to your swing palette.<br></br>
6. Now just add the buttons just like any other swing controls (Change the 'text' property to blank so the buttons just shows as an icon).
Now your screen should look something like this:<br></br>
<img src="images/netbeansvisualbuilder2.jpg"></img><br></br>
7. You need to listen for the JCalendarButton property changes so your text fields will change.
The code should look something like this:<br></br>
<code>
    private void dateOnlyPopupChanged(java.beans.PropertyChangeEvent evt) {<br></br>
        if (evt.getNewValue() instanceof Date)<br></br>
            setDate((Date)evt.getNewValue());<br></br>
    }<br></br>
</code>and
Then make sure the JCalendarButtons
are notified of any manually entered date changes, so they will default to the current field value.
The code should look something like this:<br></br>
<code>
    jCalendarButton1.setTargetDate(date);<br></br>
</code>
<br></br>
<i>Viola!</i> That's it! <a href="code2/NewJFrame.java">Click here to see the final source code.</a>
</p>

<p>
<a href="index.html>Back to main documentation page</a><br></br>
<a href="http://www.sourceforge.net/projects/jcalendarbutton" > 
Project page at </a>
<a href="http://jcalendarbutton.sourceforge.net/" ><img src="http://sourceforge.net/sflogo.php?group_id=239200&type=3" width="88" height="31" alt="SourceForge" />
</a>
</p>
</body>
</html>